<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui"
	template="/templates/template.xhtml" xmlns:eq="http://www.equus.com.br/facelets/">

	<f:metadata>
		<f:event type="preRenderView" listener="#{avaliacaoAnimalBean.verificarAcesso}" />
	</f:metadata>

	<ui:define name="body">
		<h:form id="form" prependId="false">
			<h:panelGrid id="tagOs" width="100%">
				<eq:animal animal="#{avaliacaoAnimalBean.animal}" />
			</h:panelGrid>
			<p:fieldset legend="#{avaliacaoAnimalBean.qualifiedName}" id="fieldPrincipal">
				<h:panelGrid columns="4" id="panelAvaliacao" columnClasses="coluna15,coluna40,coluna20,coluna35" width="100%">

					<h:outputText value="Data Avaliação:" styleClass="icoObrigatorio" />
					<h:panelGrid columns="2" cellpadding="0" cellspacing="0">
						<p:calendar locale="pt" pattern="dd/MM/yyyy" id="dtAva" navigator="true" maxlength="10" size="15"
							readOnlyInputText="true" value="${avaliacaoAnimalBean.model.dtAvaliacao}" mode="popup" showOn="button"
							requiredMessage="#{avaliacaoAnimalBean.requiredMessage}" required="true" />
					</h:panelGrid>
					<p:message for="dtAva" />
					<h:outputText value=" " />

					<h:outputLabel value="Usuário:" for="userAvaliacao" styleClass="icoObrigatorio" />
					<p:autoComplete queryDelay="500" size="50" value="#{avaliacaoAnimalBean.userAvaliacao}" minQueryLength="2"
						id="userAvaliacao" completeMethod="#{avaliacaoAnimalBean.completeUsuario}" forceSelection="true" var="user"
						itemLabel="#{user.nome}" itemValue="#{user.id}" converter="usuarioConverter"
						requiredMessage="#{perfilBean.requiredMessage}" required="true" />
					<p:message for="userAvaliacao" />
					<h:outputText value=" " />

					<h:outputLabel value="Situação Casco:" styleClass="icoObrigatorio" />
					<p:selectOneMenu id="idCasco" effect="fade" style="width:300px;" value="#{avaliacaoAnimalBean.idAvaliacaoCasco}"
						requiredMessage="#{perfilBean.requiredMessage}" required="true">
						<f:selectItem itemLabel="Selecione" itemValue="" />
						<f:selectItems value="#{avaliacaoAnimalBean.listaTipoAvaliacao}" />
					</p:selectOneMenu>
					<p:message for="idCasco" />
					<h:outputText value=" " />

					<h:outputLabel value="Avaliação Dentição:" styleClass="icoObrigatorio" />
					<p:selectOneMenu id="idDenticao" effect="fade" style="width:300px;"
						value="#{avaliacaoAnimalBean.idAvaliacaoDenticao}" requiredMessage="#{perfilBean.requiredMessage}" required="true">
						<f:selectItem itemLabel="Selecione" itemValue="" />
						<f:selectItems value="#{avaliacaoAnimalBean.listaTipoAvaliacao}" />
					</p:selectOneMenu>
					<p:message for="idDenticao" />
					<h:outputText value=" " />

					<h:outputLabel value="Observação Dentição:" styleClass="icoObrigatorio" />
					<p:inputTextarea autoResize="false" value="#{avaliacaoAnimalBean.model.denticao}" id="obsDenticao" cols="50"
						rows="5" requiredMessage="#{perfilBean.requiredMessage}" required="true" />
					<p:message for="obsDenticao" />
					<h:outputText value=" " />

					<h:outputLabel value="Peso:" styleClass="icoObrigatorio" />
					<p:inputText value="#{avaliacaoAnimalBean.model.pesoToString}" id="idPeso" size="20" maxlength="7"
						requiredMessage="#{perfilBean.requiredMessage}" required="true" />
					<p:message for="idPeso" />
					<h:outputText value=" " />

					<h:outputLabel value="Circ. Toráxica:" styleClass="icoObrigatorio" />
					<p:inputText value="#{avaliacaoAnimalBean.model.cincurferenciaToString}" id="idcircuferencia" size="20"
						maxlength="7" requiredMessage="#{perfilBean.requiredMessage}" required="true" />
					<p:message for="idcircuferencia" />
					<h:outputText value=" " />

					<h:outputLabel value="Informação Nutricional:" />
					<p:inputTextarea autoResize="false" value="#{avaliacaoAnimalBean.model.nutricional}" id="nutricional" cols="50"
						rows="5" />
					<h:outputText value=" " />
					<h:outputText value=" " />


					<h:outputLabel value="Situação do Caso:" />
					<p:inputTextarea autoResize="false" value="#{avaliacaoAnimalBean.model.situacaoCasco}" id="sitCasco" cols="50"
						rows="5" />
					<h:outputText value=" " />
					<h:outputText value=" " />

					<h:outputLabel value="Observação:" />
					<p:inputTextarea autoResize="false" value="#{avaliacaoAnimalBean.model.observacao}" id="obsAvaliacao" cols="50"
						rows="5" />
					<h:outputText value=" " />
					<h:outputText value=" " />
					
				 </h:panelGrid>
				<br />
				<p:toolbar>
					<p:toolbarGroup align="left">
						<p:commandButton value="Voltar" immediate="true" ajax="false" action="pesquisarAnimal.jsf" />
						<p:commandButton value="Limpar" immediate="true" ajax="false" action="#{avaliacaoAnimalBean.limparTela}" />
						<p:commandButton rendered="#{p:ifGranted('ROLE_AVALIACAO_SALVAR')}" value="Salvar" ajax="true" process="@form"
							update="@form" action="#{avaliacaoAnimalBean.save}" />
					</p:toolbarGroup>
				</p:toolbar>
				<br />
				<p:dataTable var="avaliacao" id="listaAvaliacao" emptyMessage="#{avaliacaoAnimalBean.emptyMessage}"
					update="listaAvaliacao" rowsPerPageTemplate="#{avaliacaoAnimalBean.paginacao}" styleClass="coluna100"
					value="#{avaliacaoAnimalBean.lazyDataModel}" paginator="true" rows="5"
					rowStyleClass="#{empty rowIx or rowIx mod 2 ne 0 ? 'linhaImpar' : 'linhaPar'}" rowIndexVar="rowIx">

					<p:column headerText="Usuário" filterBy="#{avaliacao.usuario.nome}" sortBy="#{avaliacao.usuario.nome}"
						style="width:15%">
						<h:outputLabel value="#{avaliacao.usuario.nome}" />
					</p:column>
					<p:column headerText="Casco" filterMatchMode="contains" filterBy="#{avaliacao.avaliacaoCasco.descricao}"
						sortBy="#{avaliacao.avaliacaoCasco.descricao}" style="width:10%">
						<h:outputLabel value="#{avaliacao.avaliacaoCasco.descricao}" />
					</p:column>
					<p:column headerText="Dentição" filterBy="#{avaliacao.avaliacaoDenticao.descricao}"
						sortBy="#{avaliacao.avaliacaoDenticao.descricao}" style="width:15%">
						<h:outputLabel value="#{avaliacao.avaliacaoDenticao.descricao}" />
					</p:column>
					<p:column headerText="Peso" sortBy="#{avaliacao.peso}" style="width:10%">
						<h:outputLabel value="#{avaliacao.peso}" />
					</p:column>
					<p:column headerText="Circ. Toráxica" sortBy="#{avaliacao.cincurferencia}" style="width:15%">
						<h:outputLabel value="#{avaliacao.cincurferencia}" />
					</p:column>
					<p:column headerText="Nutricional" filterMatchMode="contains" filterBy="#{avaliacao.nutricional}" style="width:15%">
						<h:outputLabel value="#{avaliacao.nutricional}" />
					</p:column>
					<p:column headerText="Avaliacao" sortBy="#{avaliacao.dtAvaliacao}" style="width:10%">
						<h:outputLabel value="#{avaliacao.dtAvaliacao}">
							<f:convertDateTime pattern="dd/MM/yyyy" />
						</h:outputLabel>
					</p:column>

					<p:column headerText="Ações" style="width:10%;text-align:center;">
						<p:commandLink rendered="#{p:ifGranted('ROLE_AVALIACAO_EDITAR')}" title="Editar" style="padding:5px !important;"
							update=":form:panelAvaliacao" process="@this" action="#{avaliacaoAnimalBean.load}">
							<h:graphicImage library="design/imagem" name="icone-editar.png" />
							<f:setPropertyActionListener target="#{avaliacaoAnimalBean.model}" value="#{avaliacao}" />
						</p:commandLink>
						<p:commandLink rendered="#{p:ifGranted('ROLE_AVALIACAO_EXCLUIR')}" title="Excluir" process="@this"
							oncomplete="confirmationAvaliacao.show()">
							<h:graphicImage library="design/imagem" name="icone-excluir.png" />
							<f:setPropertyActionListener target="#{avaliacaoAnimalBean.model}" value="#{avaliacao}" />
						</p:commandLink>
					</p:column>
				</p:dataTable>
				<p:confirmDialog appendToBody="true" message="Confirma a Exclusão" header="Exclusão" severity="alert"
					widgetVar="confirmationAvaliacao">
					<h:panelGrid columns="2">
						<p:commandButton value="Sim" update="listaAvaliacao" oncomplete="confirmationAvaliacao.hide()"
							actionListener="#{avaliacaoAnimalBean.delete}" immediate="true" />
						<p:commandButton value="Não" onclick="confirmationAvaliacao.hide()" />
					</h:panelGrid>
				</p:confirmDialog>
			</p:fieldset>
		</h:form>
	</ui:define>
</ui:composition>